#pragma once

#include <memory>
#include <vector>

#include "asycipc/api.hpp"
#include "asycipc/transport.hpp"

namespace asycipc {

class ServerConnection {
 public:
  ServerConnection(PipeServer& server, PipeHandlePtr handle,
                   std::unique_ptr<Channel> channel);

  Channel& channel() { return *channel_; }
  PipeHandle& handle() { return *handle_; }

  bool PumpOnce();
  void FlushMaintenance();

 private:
  void WriteFrames(const std::vector<Frame>& frames);

  PipeServer& server_;
  PipeHandlePtr handle_;
  std::unique_ptr<Channel> channel_;
};

}  // namespace asycipc
